package com.itheima.search.task;

import com.itheima.search.config.SpringContext;
import com.itheima.search.dto.SearchDto;
import com.itheima.search.service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @Author：shenkunlin
 * @date： 2021/9/2 15:52
 * @Description：
 ***/
public class SyncKeyword implements Runnable {

    //线程所需的数据
    private Map<String,Object> dataMap;

    public SyncKeyword(Map<String, Object> dataMap) {
        this.dataMap = dataMap;
    }

    /***
     * 运行的程序-执行任务
     */
    @Override
    public void run() {
        ApUserSearchService apUserSearchService = SpringContext.getBean(ApUserSearchService.class);
        SearchDto searchDto = (SearchDto) dataMap.get("dto");
        apUserSearchService.saveSearch(searchDto);
    }
}
